package com.apeli.web;

import com.apeli.config.PatternProperties;
import com.apeli.pojo.User;
import com.apeli.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Slf4j
@RestController
@RequestMapping("/user")
// @RefreshScope
public class UserController {

    @Autowired
    private UserService userService;
    @GetMapping("/{id}")
    public User queryById(@PathVariable("id") Long id,
                          @RequestHeader(value = "User-Agent",defaultValue = "apeli") String userAgent) {
        System.out.println("user-agent: " + userAgent);
        return userService.queryById(id);
    }

    @GetMapping("map")
    public  String mapToTransfer(String name)
    {
        return  name;
    }

    @PostMapping
    public  User save(User user)
    {
        user.setAddress("1237");
        System.out.println("save success...");
        return  user;
    }
}
